package com.chennan.concurrency.synchroni;

import java.util.concurrent.TimeUnit;

/**
 * @author chennan
 * @create 2022-04
 */
public class DoubleMethod {

    public static void main(String[] args) {
        DoubleMethod doubleMethod = new DoubleMethod();
        new Thread(()->{
            doubleMethod.get1();
        }).start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            doubleMethod.get2();
        }).start();
    }


    public synchronized void get1() {
        System.out.println("get1");

        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public synchronized void get2(){
        System.out.println("get2");
    }
}
